PATHMac OS 8 and 9 Developer Documentation > Networking and Communications > URL Access Manager >

Transferring Files With the URL Access Manager


URLSimpleUpload

Uploads a file or directory synchronously to an FTP URL.

OSStatus URLSimpleUpload (
                     char* url,
                     FSSpec* source,
                     URLOpenFlags openFlags,
                     URLSystemEventProcPtr eventProc,
                     void* userContext);
url
A pointer to the FTP URL to which a file or directory is to be uploaded. To specify the name of the resulting file or directory, set url to a fully specified URL that does not end with a slash (/) character. If the file or directory exists and you want to replace it, specify the path to the destination directory, terminate the path with a slash (/), and specify kURLReplaceExistingFlag in the openFlags parameter. If you specify a name that already exists on the server and you do not specify kURLReplaceExistingFlag in the openFlags parameter, URLSimpleUpload returns the error kURLDestinationExistsError . If you do not specify a name, do not specify kURLReplaceExistingFlag , and the name already exists on the server, the URL Access Manager creates a unique name by appending a number to the original name before the extension, if any.
source
A pointer to a structure of type FSSpec . Before calling URLSimpleUpload , set the structure to specify the file or directory you want to upload. See Inside Macintosh: Files for more information about the FSSpec structure.
openFlags
A value of type URLOpenFlags that specifies upload options. The following constants can be used to specify upload options:
kURLReplaceExistingFlag kURLBinHexFileFlag kURLDisplayProgressFlag kURLDisplayAuthFlag kURLDoNotTryAnonymousFlag
See Open Flag Constants for descriptions of these constants.
eventProc
A value of type URLSystemEventProcPtr that points to an application-defined system event callback routine System Event Callback Routine that the URL Access Manager calls to communicate system events to your application during the upload process. If your application requests the display of a progress indicator or authentication dialog box, these items appear in a movable modal dialog box.
The value of eventProc can be NULL , in which case your application will not be informed of system events. If your application requests the display of a progress indicator or authentication dialog box, these items appear in a nonmovable modal dialog box.
userContext
An untyped pointer to arbitrary data that the URL Access Manager passes to the application-defined system event callback routine specified by eventProc . Your application can use userContext to associate a callback with a particular call to URLSimpleUpload .
function result
A result code. For a list of possible result codes, see Result Codes .

DISCUSSION

The URLSimpleUpload function uploads data synchronously to the specified FTP URL from the specified file or directory and does not return until the upload is complete. The URLSimpleUpload function yields time to other threads. Your application should call URLSimpleUpload from a thread other than the main thread so that other processes have time to run.

If you want a progress indicator to be displayed during the upload, specify kURLDisplayProgressFlag in the openFlags parameter. The URL Access Manager uses a modal dialog box to display the progress indicator.

If your application has multiple threads, it can call URLSimpleUpload multiple times, but if it calls URLSimpleUpload with kURLDisplayProgressFlag set in openFlags when the URL Access Manager is already displaying a modal dialog box, URLSimpleUpload returns the error kURLProgessAlreadyDisplayedError .

Call URLUpload if you need to set properties or URLOpen if you need to control the upload process.


© 1999 Apple Computer, Inc. – (Last Updated 07 May 99)